package com.cn.dream_order_server.service.impl;

import com.cn.dream_order_server.service.LogisticsManagementService;
import com.cn.dream_order_server.vo.LogisticsManagementVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class LogisticsManagementServiceImpl implements LogisticsManagementService {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public List<LogisticsManagementVO> getLogisticsManagementMsg(String orderOrder1) {
        String s = stringRedisTemplate.opsForValue().get("LogisticsManagement-" + orderOrder1);
        List<LogisticsManagementVO> list = new ArrayList<LogisticsManagementVO>();
        if (s!=null&&!"".equals(s)){
            String[] split = s.split(",");
            for (int i = split.length-1; i >=0 ; i--) {
                String[] split1 = split[i].split("\\*");
                LogisticsManagementVO logisticsManagementVO = new LogisticsManagementVO();
                logisticsManagementVO.setDateTimeStr(split1[0]);
                logisticsManagementVO.setMsg(split1[1]);
                list.add(logisticsManagementVO);
            }
        }
        return list;
    }
}
